package me.haoliang.controller;

import me.haoliang.service.UserService;
import me.haoliang.vo.UserVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import javax.annotation.Resource;

/**
 * Created by pulangke on 2017/5/22.
 */
@RestController
public class UserController {

    @Resource
    private UserService userService;


    @GetMapping("/getAll")
    public Flux<UserVo> list() {
        return Flux.fromIterable(userService.getUsers());
    }

    @GetMapping("/hello")
    public Mono<String> hello() {
        return Mono.just("hello world");
    }

    @GetMapping("/get/{id}")
    public Mono<UserVo> get(@PathVariable Integer id) {
        return Mono.just(userService.getUser(id));
    }


}
